﻿using System;
using System.Collections.Generic;
using System.Text;
using Android.Util;
using Android.View;
using LeePong.Game.Shapes;

namespace LeePong.Android.Interaction
{
    public class GestureHandler : GestureDetector.SimpleOnGestureListener
    {
        private GameSurface _surface;

        public GestureHandler(GameSurface surface)
        {
            this._surface = surface;
        }

        public override bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
        {
            //  Log.D("-------------", "OnScroll X:" + e1.GetX(0) + " Y:" + e1.Y + " dX:" + distanceX + " dY:" + distanceY);
            this._surface.Engine.TouchScroll(new Coordinates(e2.X, e2.Y), new Coordinates(e2.X + distanceX, e2.Y + distanceY));
            return true;
        }

        public override bool OnSingleTapUp(MotionEvent e)
        {
            return true;
        }

        public override bool OnDown(MotionEvent e)
        {
            this._surface.Engine.TouchSingleTap(new Coordinates(e.X, e.Y));
            //  Log.D("-------------", "" + e.GetPointerCount());
            return true;
        }

        public override bool OnFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
        {
            // Log.D("-------------", "x:" + e2.X + " velx:" + velocityX + " vely:" + velocityY);
            return true;
        }
    }
}
